home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VLA_FONT.ZIP / HSCRSINE.ASM < prev    next >
Assembly Source File  |  1993-09-27  |  7KB  |  298 lines

  1.     IDEAL
  2.     DOSSEG
  3.     MODEL SMALL
  4.     STACK 200h
  5.     CODESEG
  6.     p386
  7.     
  8.     ASSUME CS:@CODE, DS:@CODE
  9. ────────────────────────────────────────────────────────────────────────────
  10. STRUC VCHHDR
  11.     Ident   db  "VLACH"
  12.     From    db  ?
  13.     X       db  ?
  14.     Y       db  ?
  15.     NumChar db  ?
  16. ENDS
  17.  
  18. STRUC Pal
  19.     R       db  ?
  20.     G       db  ?
  21.     B       db  ?
  22. ENDS
  23. ────────────────────────────────────────────────────────────────────────────
  24. INCLUDE "MODEX.INC"
  25. SCReenWidth     =       130
  26.  
  27. FileName_VCH    db      "Font5.VCH",0
  28. FileName_PAL    db      "Font5.PAL",0
  29.  
  30. Seg_VCH         dw      0
  31.  
  32. Palette         Pal     256 dup (<>)
  33. VCHHEADER       VCHHDR  <>
  34. CharWidths      db      256 dup (0)
  35.  
  36. TheMessage      db      " THIS VERSION IS SUPPOSEDTO BE UNREADABLE...  "
  37.                 db      "BUT YOU PROBABLY COULD HAVE GUESSED THAT...    "
  38.                 db      "   THE RESOLUTION IS CHANGING FROM 480 HIGH TO 15!  "
  39.                 db      "@@@@@@@@      ",0
  40.  
  41. MsgOff          dw      offset TheMessage
  42. CharOff         dw      0       ;offset to current column to draw of chr
  43. XYsize          dw      ?       ;number of bytes in a char
  44. CurColumn       db      1
  45. BaseDestOff     =       ScreenWidth * 10
  46. DestOff         dw      BaseDestOff
  47.  
  48. PlusAdd         dw      0
  49. ────────────────────────────────────────────────────────────────────────────
  50.     ────────────────────────────────────────────────────────────────────
  51.     ; Load in the font named in FileName_VCH and loads in the Palette
  52.     ; named in FileName_PAL. 
  53.     ;
  54.     ; Returns CF = 1 if there was an error
  55.     ────────────────────────────────────────────────────────────────────
  56. PROC LoadFont NEAR
  57.     pusha
  58.     push    ds
  59.  
  60.     mov     ax,cs
  61.     mov     ds,ax
  62.     mov     dx,offset FileName_PAL      ;open the palette file
  63.     mov     ax,3d00h
  64.     int     21h
  65.     jc      @@Error
  66.     mov     bx,ax
  67.  
  68.     mov     dx,offset Palette           ;read in the palette
  69.     mov     cx,768
  70.     mov     ah,3fh
  71.     int     21h
  72.  
  73.     mov     ah,3eh                      ;close PAL file
  74.     int     21h
  75.  
  76.     mov     dx,offset FileName_VCH      ;open VCH file
  77.     mov     ax,3d00h
  78.     int     21h
  79.     jc      @@Error
  80.     mov     bx,ax
  81.  
  82.     mov     dx,offset VCHHeader         ;load in the header
  83.     mov     cx,size VCHHDR
  84.     mov     ah,3fh
  85.     int     21h
  86.  
  87.     mov     al,[VCHHEADER.X]            ;calc data size
  88.     mul     [VCHHEADER.Y]
  89.     mov     [XYsize],ax
  90.     movzx   cx,[VCHHEADER.NumChar]
  91.     mul     cx
  92.     mov     cx,ax
  93.  
  94.     mov     ax,[cs:SEG_VCH]             ;move SEG_VCH into DS, but be sure
  95.     or      ax,ax                       ;the segment isn't 0
  96.     stc
  97.     je      @@Error
  98.     mov     ds,ax
  99.     xor     dx,dx                       ;load in the data
  100.     mov     ah,3fh
  101.     int     21h
  102.  
  103.     mov     ax,cs
  104.     mov     ds,ax
  105.     mov     dx,offset CharWidths
  106.     movzx   cx,[VCHheader.NumChar]
  107.     mov     ah,3fh
  108.     int     21h                         ;read in widths of chars
  109.  
  110.     mov     ah,3eh                      ;close VCH file
  111.     int     21h
  112.     clc
  113.  
  114. @@Error:
  115.  
  116.     pop     ds
  117.     popa
  118.     ret
  119. ENDP
  120.     ────────────────────────────────────────────────────────────────────
  121.     ;Starts the next letter in the message
  122.     ────────────────────────────────────────────────────────────────────
  123. PROC NewChar NEAR
  124.     pusha
  125.     push    ds
  126.     mov     ax,cs
  127.     mov     ds,ax
  128.  
  129.     mov     si,[MsgOff]     ;get the offset to the next char
  130. @@MsgLoop:
  131.     lodsb
  132.     or      al,al
  133.     jne     @@IsaChar
  134.     mov     si,offset TheMessage
  135.     jmp short @@MsgLoop
  136.  
  137. @@IsaChar:
  138.     mov     ah,[VCHHEADer.From]
  139.     add     ah,[VCHHEADer.NumChar]
  140.     cmp     al,[VCHHEADer.FROM]
  141.     jb      @@MsgLoop
  142.     cmp     al,ah
  143.     ja      @@MsgLoop
  144.  
  145.     mov     [MsgOff],si
  146.     sub     al,[VCHheader.From]
  147.     movzx   ax,al
  148.     mov     bx,ax
  149.     mul     [XYsize]
  150.     mov     [CharOff],ax
  151.     
  152.     mov     al,[CharWidths + bx]
  153.     mov     [CurColumn],al
  154.     
  155.     pop     ds
  156.     popa
  157.     ret
  158. ENDP
  159.     ────────────────────────────────────────────────────────────────────
  160.     ; Draws the Next column onto the screen, calls NewChar if done with
  161.     ; current character
  162.     ────────────────────────────────────────────────────────────────────
  163. PROC DrawColumn NEAR
  164.     pusha
  165.     push    ds es fs
  166.     mov     ax,cs
  167.     mov     ds,ax
  168.  
  169.     mov     bx,[DestOff]
  170.     add     bx,2
  171.     ;sub     bx,[PlusAdd]
  172.     sub     bx,6*ScreenWidth
  173.     @Set_Start_Offset
  174.  
  175.     dec     [CurColumn]
  176.     jne     @@NoNew
  177.  
  178.     call    NewChar
  179.  
  180. @@NoNew:
  181.     mov     fs,[SEG_VCH]
  182.     mov     es,[VGASEG]
  183.     mov     si,[CharOff]    ;fs:si points to the data
  184.     mov     di,[DestOff]
  185.  
  186.     movzx   dx,[VCHheader.X]
  187.     movzx   cx,[VCHheader.Y]
  188.     mov     bp,SCReenWidth         ;screen width
  189.  
  190. @@Zloop:
  191.     mov     al,[fs:si]
  192.     mov     [es:di],al
  193.     mov     [es:di+SCReenWidth/2],al
  194.     add     di,bp
  195.  
  196.     add     si,dx
  197.  
  198.     loop    @@ZLoop
  199.  
  200.     inc     [DestOff]
  201.     cmp     [DestOff],ScreenWidth/2 + BaseDestOff
  202.     jb      @@okok
  203.  
  204.     sub     [DestOff],ScreenWidth/2
  205.  
  206. @@okok:
  207.     inc     [CharOff]
  208.  
  209.     pop     fs es ds
  210.     popa
  211.     ret
  212. ENDP
  213.  
  214. Hindex  dw  0
  215. SINE    db  15,15,16,16,16,17,17,18,18  
  216.         db  18,19,19,19,20,20,20,21,21,21  
  217.         db  22,22,22,23,23,23,24,24,24,25  
  218.         db  25,25,25,26,26,26,26,27,27,27  
  219.         db  27,27,28,28,28,28,28,29,29,29  
  220.         db  29,29,29,29,29,30,30,30,30,30  
  221.         db  30,30,30,30,30,30,30,30,30,30  
  222.         db  30,30,30,30,30,30,29,29,29,29  
  223.         db   29,29,29,29,28,28,28,28,28,27  
  224.         db   27,27,27,27,26,26,26,26,25,25  
  225.         db   25,25,24,24,24,23,23,23,22,22  
  226.         db   22,21,21,21,20,20,20,19,19,19  
  227.         db   18,18,18,17,17,16,16,16,15,15  
  228.         db   15,14,14,14,13,13,12,12,12,11  
  229.         db   11,11,10,10,10,9,9,9,8,8  
  230.         db   8,7,7,7,6,6,6,5,5,5  
  231.         db   5,4,4,4,4,3,3,3,3,3  
  232.         db   2,2,2,2,2,1,1,1,1,1  
  233.         db   1,1,1,0,0,0,0,0,0,0  
  234.         db   0,0,0,0,0,0,0,0,0,0  
  235.         db   0,0,0,0,1,1,1,1,1,1  
  236.         db   1,1,2,2,2,2,2,3,3,3  
  237.         db   3,3,4,4,4,4,5,5,5,5  
  238.         db   6,6,6,7,7,7,8,8,8,9  
  239.         db   9,9,10,10,10,11,11,11,12,12  
  240.         db   12,13,13,14,14,14,15 
  241.  
  242. PROC DoHeight NEAR
  243.     push    bx dx ax
  244.  
  245.     add     [BYTE cs:Hindex],5
  246.     mov     bx,[cs:Hindex]
  247.     mov     ah,[cs:Sine+bx]
  248.     
  249.     mov     dx,CRTC_Index
  250.     mov     al,9
  251.     out     dx,ax
  252.  
  253.     movzx   ax,[cs:Sine+bx]
  254.     xor     al,11111b
  255.     imul    ax,ScreenWidth
  256.     mov     [cs:PlusAdd],ax
  257.  
  258.     pop     ax dx bx
  259.     ret
  260. ENDP
  261. ────────────────────────────────────────────────────────────────────────────
  262. START:
  263.     mov     ax,cs
  264.     mov     ds,ax
  265.  
  266.     mov     ax,ss
  267.     mov     bx,sp
  268.     add     bx,15
  269.     shr     bx,4
  270.     add     ax,bx
  271.     mov     [SEG_VCH],ax
  272.  
  273.     @SetModeX m256x70x256, 520
  274.  
  275.     call    LoadFont
  276.     mov     si,offset Palette
  277.     mov     cx,256
  278.     mov     al,0
  279.     @WritePalette
  280.  
  281. @@MainLoop:
  282.     @FullVertWait
  283.     call    DrawColumn
  284.     call    DoHeight
  285.  
  286.     mov     ah,1
  287.     int     16h
  288.     jz      @@MainLoop
  289.  
  290.     mov     ah,0
  291.     int     16h
  292.  
  293.     mov     ax,3
  294.     int     10h
  295.     mov     ax,4c00h
  296.     int     21h
  297. END START
  298.